package com.zjitc.book.common.result;

import lombok.Data;

@Data
public class R<T> {

    private Integer code;
    private String message;
    private T data;

    public static <T> R<T> success(T data){
        R<T> r =new R<>();
        r.setCode(200);
        r.setMessage("success");
        r.setData(data);
        return r;
    }
    public static <T> R<T> success(T data,String msg){
        R<T> r =new R<>();
        r.setCode(200);
        r.setMessage(msg);
        r.setData(data);
        return r;
    }
    public static <T> R<T> success(){
        return success(null,"");
    }
    public static <T> R<T> error(String msg){
        R<T> r =new R<>();
        r.setCode(500);
        r.setMessage(msg);
        return r;
    }
    public static <T> R<T> error(Integer code,String msg){
        R<T> r =new R<>();
        r.setCode(code);
        r.setMessage(msg);
        return r;
    }
}
